package test.Tread;


public class Supplier extends Thread{

	private Storage storage;
	
	public Supplier( Storage storage)
	{
		this.storage=storage;
	}
	
	@Override
	public void run() {
		while(1==1){
			synchronized (storage) {
				if(storage.list.size()==0)
				{
					System.out.println(this.getName()+"开始生产............库存大小:"+storage.list.size());
					for(int i=0;i<storage.total;i++)
					{
						storage.list.add("a"+i);
						System.out.println("a"+i);
					}
					System.out.println(this.getName()+"结束生产............库存大小:"+storage.list.size());
					storage.notifyAll();
				}else
				{
					try {
						storage.wait(); 
						System.out.println(this.getName()+"厂商休息下1000");
						this.sleep(1000);
					} catch (InterruptedException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
			}
		}
	}

	public void  start(Storage storage){
		this.start();
	}
	
}
